package com.wly.data
{
	public class ItemVO
	{
		public var id:int;
		public var url:String;
		public var width:int;
		public var height:int;
		public var types:Array = [];
		
		public function addType(type:TypeVO):void
		{
			if(!type)
			{
				return;
			}
			
			if(isContainType(type))
			{
				return;
			}
			types.push(type.id);
			types.sort(Array.NUMERIC);
		}
		
		private function isContainType(type:TypeVO):Boolean
		{
			var i:int;
			var ellment:int;
			
			if(!type)
			{
				return false;
			}
			
			for(i=0; i<types.length; i++)
			{
				ellment = types[i];
				if(ellment == type.id)
				{
					return true;
				}
			}
			
			return false;
		}
		
		public function deType(type:TypeVO):void
		{
			if(!type || !isContainType(type))
			{
				return;
			}
			
			types = types.filter(elementTest);
			
			function elementTest(item:*, index:int, array:Array):Boolean
			{
				if(item == type.id)
				{
					return false;
				}
				return true;
			}
		}
		
		private function elementTest(item:*, index:int, array:Array):Boolean
		{
			return false;
		}
	}
}